feat: accept api_key= on client, transcriber, and streaming constructors - #231
Merged
Merged
Conversation
ccampbell-aai
force-pushed
the
ccampbell/api-key-constructors
branch
from
August 14, 2026 01:39
ab1a1ec to
8b1920a
Compare
ccampbell-aai
marked this pull request as ready for review
August 14, 2026 01:49
Client and AsyncClient take an optional api_key= and make settings= optional, defaulting to a copy of the global settings; the missing-key error now names all three ways to supply one. Transcriber, AsyncTranscriber, SyncTranscriber, and AsyncSyncTranscriber take api_key= and build their own client from it, keeping the ownership semantics of the default-constructed client. Passing both client= and api_key= raises ValueError. StreamingClient and AsyncStreamingClient take a keyword-only api_key= and make options= optional; api_key= takes precedence over a key on options, applied to a copy so the caller's object is never mutated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ccampbell-aai
force-pushed
the
ccampbell/api-key-constructors
branch
from
August 14, 2026 01:57
8b1920a to
c280e07
Compare
aurpsis-aai
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a direct
api_key=path everywhere a user constructs an SDK object, so authenticating no longer requires the globalaai.settings.api_keyor building aClient(settings=Settings(...))chain by hand. Strictly additive — every existing call site behaves identically.Client/AsyncClient:settingsis now optional (defaults to a copy of the global settings) andapi_key=overrides the key on the client's own settings copy. The global settings object is never mutated.Transcriber,AsyncTranscriber,SyncTranscriber,AsyncSyncTranscriber:api_key=builds an owned client with the same lifecycle as the default path. Given alongsideclient=, the kwarg takes precedence: since a client's credentials are baked into its connection pool at construction, the transcriber derives and owns a new client from a copy of that client's settings with the key replaced — the given client is left untouched and stays the caller's to close.StreamingClient/AsyncStreamingClient:optionsbecomes optional andapi_key=is accepted alongside it — the constructor key takes precedence overoptions.api_keyon a copy (the caller's options object is never mutated; all other fields carry over). No credentials at all now raises an actionableValueErrorinstead of a bareTypeError.ASSEMBLYAI_API_KEYenv var,aai.settings.api_key, andapi_key=.Bumps the version to 0.68.00 (minor).
Tests: 29 new construction-level tests in
tests/unit/test_dx.py; full suite 434 passed with the 405 pre-existing tests untouched.🤖 Generated with Claude Code